﻿namespace Ficharts.Net
{
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public abstract class FiChartBase : WebControl
    {
        [PersistenceMode(PersistenceMode.InnerProperty)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [NotifyParentProperty(true)]
        [Category("图表属性")]
        [Description("图标属性-图表后缀")]
        public SuffixPropertySet Suffix { get; set; }

        public abstract string ToXml();

        protected FiChartBase()
        {
            ChartTitle = new ChartTitlePropertySet();
            Suffix = new SuffixPropertySet();
            Legend = new LegendPropertySet();
        }

        /// <summary>
        /// 初始动画，默认第一次渲染时有动画效果
        /// </summary>
        [ChartConfig]
        public bool? Animation { get; set; }

        /// <summary>
        /// 开启后双击图表空白区域会全屏显示，再次双击或按下Esc键后推出退出全屏模式
        /// </summary>
        [ChartConfig]
        public bool? FullScreen { get; set; }

        /// <summary>
        /// 保留小数点位数，仅对数字类型数据有效
        /// </summary>
        [ChartConfig]
        public int? Precision { get; set; }

        [ChartProperty]
        public LegendPropertySet Legend { get; set; }

        private ChartTitlePropertySet chartTitle;

        [PersistenceMode(PersistenceMode.InnerProperty)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [NotifyParentProperty(true)]
        [Category("图表属性")]
        [Description("图标属性-图表标题")]
        public ChartTitlePropertySet ChartTitle
        {
            get
            {
                return this.chartTitle ?? (this.chartTitle = new ChartTitlePropertySet());
            }
            set
            {
                chartTitle = value;
            }
        }

        private List<SeriesBase> series;

        [PersistenceMode(PersistenceMode.InnerProperty)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Category("图表属性")]
        [Description("图标属性-图表")]
        public List<SeriesBase> Series
        {
            get
            {
                return this.series ?? (this.series = new List<SeriesBase>());
            }
            set { series = value; }
        }

        private List<AxisBase> xaxises;

        [PersistenceMode(PersistenceMode.InnerProperty)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Category("图表属性")]
        [Description("图标属性-X坐标轴")]
        public List<AxisBase> XAxises
        {
            get
            {
                return this.xaxises ?? (this.xaxises = new List<AxisBase>());
            }
            set
            {
                xaxises = value;
            }
        }

        private List<AxisBase> yaxises;

        [PersistenceMode(PersistenceMode.InnerProperty)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Category("图表属性")]
        [Description("图标属性-Y坐标轴")]
        public List<AxisBase> YAxises
        {
            get
            {
                return this.yaxises ?? (this.yaxises = new List<AxisBase>());
            }
            set
            {
                yaxises = value;
            }
        }
    }
}
